﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class doctor_write : System.Web.UI.Page
{
    protected Doctor doc;
    protected void Page_Load(object sender, EventArgs e)
    {
        doc = Doctor.Check();
        if (doc == null)
        {
            Session.Add(Params.SystemError, "请先登录");
            Response.Redirect(Params.RootHttp + "default.aspx");
        }
        if (!Page.IsPostBack)
        {
            this.MyDataBind();
        }
    }

    public void MyDataBind()
    {
        this.Title = this.doc.RealName + "-写信件";
        this.conNav.Title = "写信件";
        this.conRecvers.UserGuid = this.doc.Guid;
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        string t = this.tbTitle.Text.Trim();
        string b = this.tbBody.Text;
        string gs = this.conRecvers.RecversStr.Trim();
        if (t == "" || gs == "")
        {
            this.info.SetMessage("收信人和标题不能为空！");
            return;
        }
        if (gs != "")
        {
            Message.Send(this.doc.Guid, gs.Replace(" ", ","), t, b);
            Fun.Redirect("sent.aspx?uid=" + Request.Params["uid"], "发送成功");
        }
        else
        {
            this.info.SetMessage("发送失败，收件人填写错误");
        }
    }
}
